<template>
    <Layout class="menu-left">
		<Menu mode="horizontal" @on-select='lowerStep' :active-name="modaleShow">
		    <MenuItem :name="1">内部员工事故简报</MenuItem>
		    <MenuItem :name="2">相关方人员事故简报</MenuItem>
		</Menu>
        <Form ref="queryForm" :model="dataToQuery" style="margin-top: 10px;" :label-width="120">
            <Row class="query-form">
                <Col span="8">
                    <FormItem label="二级集团：">
                        <Select v-model="dataToQuery.twoLevelOrgIds" multiple :max-tag-count="1">
                            <Option v-for="item in twoOrgList" :value="item.orgId" :key="item.orgId">{{ item.orgName}}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="上报单位：">
                        <Input type="text" v-model="dataToQuery.orgName"></Input>
                    </FormItem>
                </Col>
                <Col span="8" v-if="!switchFlag">
                    <Button @click="switchQuery(true,88)" class="ivu-btn-switch" type="text">展开∨</Button>
                    <Button @click="reset1" class="ivu-btn-reset">重置</Button>
                    <Button class="ivu-btn-query" icon="md-search" @click="query()">查询</Button>
                </Col>
                <Col span="8"  v-else>
                    <FormItem label="事故类别：">
                        <Select v-model="dataToQuery.accTypeIds" multiple :max-tag-count="2">
                            <Option v-for="item in dictMap.typeList" :value="item.codingCodeId"
                                    :key="item.codingCodeId">
                                {{item.codingName}}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">
                <Col span="8">
                    <FormItem label="事故时间：">
                        <DatePicker class="query-form-el" v-model="dataToQuery.sartDateQuery" format="yyyy-MM-dd"
                                    type="daterange"
                                    placement="bottom-start"
                                    @on-change="(date) => onSelectFieldQueryDateRange(date, 'sartDate')"
                                    style="width: 100%;"></DatePicker>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="伤害程度：">
                        <Select v-model="dataToQuery.injuryLevels" multiple :max-tag-count="2">
                            <Option v-for="item in dictMap.injuryLeveList" :value="item.codingCodeId" :key="item.codingCodeId">
                                {{ item.codingName }}
                            </Option>
                        </Select>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="就业类型：">
                        <Select v-model="dataToQuery.memberships" multiple :max-tag-count="2">
                            <Option v-for="item in dictMap.membershipList" 
							:disabled="item.disabledType"
							:value="item.codingCodeId" :key="item.codingCodeId">{{item.codingName}}</Option>
                        </Select>
                    </FormItem>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">
                <Col span="8">
                    <FormItem label="年度：" prop="year" >
                        <DatePicker type="year" placeholder="请选择年度" v-model="dataToQuery.year1" clearable style="width: 100%;"
                                    @on-change="()=>{if(dataToQuery.year1 instanceof Date){dataToQuery.year = dataToQuery.year1.getFullYear().toString()}else {dataToQuery.year=null}}"></DatePicker>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="事故名称：">
                        <Input type="text" v-model="dataToQuery.sartName"></Input>
                    </FormItem>
                </Col>
                <Col span="8">
                    <Button @click="switchQuery(false,88)" class="ivu-btn-switch" type="text">收起∧</Button>
                    <Button @click="reset1" class="ivu-btn-reset">重置</Button>
                    <Button class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
                </Col>
            </Row>
            <Row class="query-form" v-if="isResult">
                <Col span="24">
                    <Button size="large" class="ivu-btn-add" icon="md-add" @click="addInfo">新增</Button>
                    <Button type="primary" class="ivu-btn-add" icon="md-cloud-download" @click="exportSubmit">导出</Button>
                    <Button type="primary" class="ivu-btn-add" icon="md-cloud-download" :loading="buttonLoading" @click="batchDownload">批量下载</Button>

                    <div class="right mt10 lh30">
                        <span style="font-size: 15px;color: red">{{titCount}}</span>
                    </div>
                </Col>
            </Row>
        </Form>
        <Table ref='table' :height="tableHeight" :loading="pageStatus.loading" size="small" class="table" no-data-text="没有查询到相关数据!"
            @on-sort-change="sortChange" show-summary sum-text="合计" :summary-method="(data) => this.gAmountTo(data,['daysWork','loseMoney','injuryDesc'])" 
            border :columns="columns1" :data="dataTable" @on-expand="onExpand">
        </Table>
        <Row style="margin-right:10px;">
            <Col span="24">
                <Page :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange"
                      style="float: right" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
                      show-total show-sizer show-elevator/>
            </Col>
        </Row>
        <Modal :title="getModalTitle('安全事故简报')" :transfer=false :mask-closable="false"
               v-model="dialogShow" v-if="dataToView && dialogShow" :width=1000 class-name='limit-height-dialog'>
            <Row>
                <Col span="24">
                    <Form ref="dialogForm" :class="mode === 'view'?'modal-view-detail':'modal-form'"
                          :show-message="false" :model="dataToView" :rules="mode === 'view'?{} :ruleCustom"
                          :label-position="mode === 'view'?'right':'top'" :label-width="mode === 'view'?110:null">
                        <Row type="flex" justify="space-around" class="code-row-bg" v-if="mode === 'view'">
                            <Col span='23'>
                                <FormItem label="事故名称：">
                                    <div>{{ dataToView.sartName }}</div>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span='7'>
                                <FormItem label="事故类别：" prop="accTypeId">
                                    <div v-if="mode === 'view'">{{ dataToView.accTypeName }}</div>
                                    <Select v-else v-model="dataToView.accTypeId">
                                        <Option v-for="item in dictMap.typeList" :value="item.codingCodeId"
                                                :key="item.codingCodeId">
                                            {{item.codingName}}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span='7'>
                                <FormItem label="事故时间：" prop="sartDate">
                                    <div v-if="mode === 'view'">{{ renderViewDate(dataToView.sartDate) }}</div>
                                    <DatePicker v-else type="date" v-model="dataToView.sartDate" placeholder="请选择事故时间" :disabled="isBelongOrg"
                                                style="width: 100%" :options="{disabledDate(date) {return date && date.valueOf() > new Date();}}" ></DatePicker>
                                </FormItem>
                            </Col>
                            <Col span='7'>
                                <FormItem label="企业负责人：" prop="chargeId">
									<Input v-if="isBelongOrg" v-model="dataToView.charge" disabled/>
                                    <div v-else-if="mode === 'view'">{{ dataToView.charge }}</div>
                                    <Select v-else v-model="dataToView.chargeId" :label-in-value="true">
                                        <Option v-for="item in chargeList" :value="item.userId" :key="item.userId">
                                            {{ item.userName }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="7">
                                <FormItem label='直接经济损失(万元)：' prop='loseMoney'>
                                    <div v-if="mode === 'view'">{{ dataToView.loseMoney }}</div>
                                    <InputNumber v-else placeholder="请填写0-9数字包括小数" :min="0" type='text' disabled
                                                 v-model='dataToView.loseMoney' style="width: 100%"></InputNumber>
                                </FormItem>
                            </Col>
                            <Col span="7">
                                <FormItem label='歇工天数：' prop="daysWork">
                                    <div v-if="mode === 'view'">{{ dataToView.daysWork }}</div>
                                    <InputNumber v-else disabled placeholder="请填写歇工天数" :min="0" type='text'
                                                 v-model='dataToView.daysWork'
                                                 style="width: 100%"></InputNumber>
                                </FormItem>
                            </Col>
                            <Col span='7'>
                                <FormItem label="二级集团安全环保管理人员：" prop="secondaryGroupPersionId">
									<Input v-if="isBelongOrg" v-model="dataToView.secondaryGroupPersion" disabled/>
                                    <div v-else-if="mode === 'view'">{{ dataToView.secondaryGroupPersion }}</div>
                                    <Select v-else v-model="dataToView.secondaryGroupPersionId" :label-in-value="true">
                                        <Option v-for="item in secondaryGroupPersionList" :value="item.userId"
                                                :key="item.userId">
                                            {{ item.userName }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="7">
                                <FormItem label='填报人：' prop="userName">
                                    <div v-if="mode === 'view'">{{ dataToView.userName }}</div>
                                    <Input v-else v-model="dataToView.userName" disabled/>
                                </FormItem>
                            </Col>
                            <Col span="7">
                                <FormItem label='填报人手机号：' prop="phone">
                                    <div v-if="mode === 'view'">{{ dataToView.phone }}</div>
                                    <Input v-else v-model="dataToView.phone" :disabled="isBelongOrg"/>
                                </FormItem>
                            </Col>
                            <Col span='7' v-if="dataToView.injuryLevelId =='1000001019000000003'">
                                <FormItem label="集团安全环保管理人员：" prop="groupPersionId">
									<Input v-if="isBelongOrg" v-model="dataToView.groupPersion" disabled/>
                                    <div v-else-if="mode === 'view'">{{ dataToView.groupPersion }}</div>
                                    <Select v-else v-model="dataToView.groupPersionId" :label-in-value="true">
                                        <Option v-for="item in groupPersionList" :value="item.userId"
                                                :key="item.userId">
                                            {{ item.userName }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span='7' v-else></Col>
                        </Row>

                        <Row>
                            <Col span="23" class="query-form" style="margin-left: 15px">
                                <Button v-show="mode !== 'view' && !isBelongOrg" class="ivu-btn-add" icon="md-add" @click="addItem">
                                    新增伤亡人员
                                </Button>
                                <Table highlight-row stripe border style="margin-top:10px;margin-bottom: 10px"
                                       :max-height="350" :columns="itemColumn"
                                       :data="dataToView.briefItems">
                                </Table>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span='23'>
                                <FormItem label="初步原因分析：" prop="accAnalyze">
                                    <div v-if="mode === 'view'">{{ dataToView.accAnalyze }}</div>
                                    <Input v-else v-model="dataToView.accAnalyze" type="textarea" :disabled="isBelongOrg"
                                           :autosize="{minRows:2,maxRows:5}"/>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span='23'>
                                <FormItem label="主要经过：" prop="accDesc">
                                    <div v-if="mode === 'view'">{{ dataToView.accDesc }}</div>
                                    <Input v-else v-model="dataToView.accDesc" type="textarea" :disabled="isBelongOrg"
                                           :autosize="{minRows:2,maxRows:5}"/>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span='23'>
                                <FormItem label='备注：' prop="notes">
                                    <div v-if="mode === 'view'">{{ dataToView.notes }}</div>
                                    <Input v-else v-model="dataToView.notes" type="textarea" :disabled="isBelongOrg"
                                           :autosize="{minRows:2,maxRows:5}"/>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="23">
                                <FormItem v-if="mode === 'view' || isBelongOrg" label="伤亡事故简报表：">
                                    <div v-show="dataToView.briefIdFiles.length>0"
                                         v-for="(item,index) in dataToView.briefIdFiles">
                                        <a @click="downloadFiles(item,index)">
                                            <span style="color: #3399ff;margin-left: 5px">{{ item.fileName }}</span></a>
                                    </div>
                                </FormItem>
                                <FormItem v-else label="伤亡事故简报表：" prop="briefIdFiles">
                                    <div>
                                        <Upload ref="upload"
                                                :before-upload="(file) => { beforeUpload(file, 'briefId') }"
                                                :show-upload-list="true"
                                                :max-size="10240"
                                                multiple
                                                type="drag"
                                                :action="fileUrl">
                                            <div style="padding: 10px">
                                                <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                                                <p>点击将文件拖拽到这里上传</p>
                                                <!--<span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>-->
                                            </div>
                                        </Upload>
                                    </div>
                                    <div v-show="dataToView.briefIdFiles.length>0"
                                         v-for="(item,index) in dataToView.briefIdFiles" :key='item'>
                                        <a @click="downloadFiles(item,index)">{{ item.fileName }}</a>
                                        <Button type="text" icon="md-trash" @click="removeFile(item.id, 'briefId')"
                                                style="margin-left: 5px;margin-bottom: 3px"/>
                                        <Progress v-show="uploadListVisible[index]"
                                                  :percent="uploadListPercent[index]"></Progress>
                                    </div>
                                </FormItem>
                            </Col>
                        </Row>

                        <Row v-if="mode != 'view'"  type="flex" justify="space-around" class="code-row-bg">
                            <Col span='23'>
                                <p>注：</p>
                                <p>1.事故类别：生产安全事故按照GB6441规定填写，其他填“交通事故、治安案件、职业病”； </p>
                                <p>2.就业类型：按照“正式工、合同工、劳务工、相关方人员”填写；</p>
                                <p>3.伤害程度：轻伤（损失工作日＜105日）、重伤（损失工作日≥105日）、死亡，损失工作日按照GB6441附录B计算</p>
                                <p>4.事故发生7天内上传此表。</p>
                            </Col>
                        </Row>
                    </Form>

                </Col>
            </Row>
            <div slot="footer">
                <Button v-if="mode != 'view'" type="primary" class='ivu-btn-save' @click="submit('dialogForm')">确定
                </Button>
                <Button v-if="mode != 'view'" type="primary" class='ivu-btn-cancel' @click="handleCancel">取消</Button>
                <Button v-if="mode === 'view'" class='ivu-btn-save' @click="dialogShow=false">关闭</Button>
            </div>
        </Modal>


        <Modal :mask-closable="false" :transfer=false v-model="itemModel" :width=600 title="伤亡人员"
               @on-cancel="itemModel=false,briefItem={}">
            <Row>
                <Col span="24">
                    <Form ref="itemForm" :class="'modal-form'" :show-message="false" :model="briefItem"
                          :rules="itemRuleCustom" label-position="top">
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='伤亡人员姓名：' prop='victim'>
                                    <Input class='query-form-el' placeholder="请填写伤亡人员姓名" type='text' :disabled="isBelongOrg"
                                           v-model='briefItem.victim'></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='性别：' prop='gender'>
                                    <!--<Input class='query-form-el' placeholder="请填写性别" type='text' v-model='dataToView.gender'></Input>-->
                                    <Select v-model="briefItem.gender" clearable :disabled="isBelongOrg">
                                        <Option v-for="item in sexList" :value="item.value" :key="item.value">{{
                                            item.text }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='年龄：' prop='age'>
                                    <InputNumber class='query-form-el' :min="0" placeholder="请填写年龄" :disabled="isBelongOrg"
                                                 v-model='briefItem.age'></InputNumber>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='岗位或工种：' prop='position'>
                                    <Input class='query-form-el' placeholder="请填写岗位或工种" type='text' :disabled="isBelongOrg"
                                           v-model='briefItem.position'></Input>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='伤害部位：' prop='injured'>
                                    <Input class='query-form-el' placeholder="请填写伤害部位" type='text' :disabled="isBelongOrg"
                                           v-model='briefItem.injured'></Input>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='就业类型：' prop='membershipId'>
                                    <!--<Input class='query-form-el' placeholder="请填写就业类型" type='text' v-model='dataToView.membershipId'></Input>-->
                                    <Select v-model="briefItem.membershipId" @on-change="selectMembership" :disabled="isBelongOrg"
                                            :label-in-value="true">
                                        <Option v-for="item in dictMap.membershipList" :value="item.codingCodeId"
                                                :key="item.codingCodeId">
                                            {{ item.codingName }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='伤害程度：' prop='injuryLevelId'>
                                    <!--<Input class='query-form-el' placeholder="请填写伤害程度" type='text' v-model='dataToView.injuryLevelId'></Input>-->
                                    <Select v-model="briefItem.injuryLevelId" @on-change="selectInJuryLevelId" :disabled="isBelongOrg"
                                            :label-in-value="true">
                                        <Option v-for="item in dictMap.injuryLeveList" :value="item.codingCodeId"
                                                :key="item.codingCodeId">
                                            {{ item.codingName }}
                                        </Option>
                                    </Select>
                                </FormItem>
                            </Col>
                            <Col span="11">
                                <FormItem label='歇工天数：' prop='daysWork'>
                                    <InputNumber class='query-form-el' placeholder="请填写歇工天数"
                                                 :disabled="daysWork" :min="0" :max="6000"
                                                 v-model='briefItem.daysWork'></InputNumber>
                                </FormItem>
                            </Col>
                        </Row>
                        <Row type="flex" justify="space-around" class="code-row-bg">
                            <Col span="11">
                                <FormItem label='直接经济损失(万元)：' prop='loseMoney'>
                                    <InputNumber class='query-form-el' placeholder="请填写0-9数字包括小数" :min="0"
                                                 v-model='briefItem.loseMoney'></InputNumber>
                                </FormItem>
                            </Col>
                            <Col span="11"></Col>
                        </Row>
                    </Form>
                </Col>

            </Row>
            <div slot="footer">
                <Button type="primary" class='ivu-btn-save' @click="itemSubmit('itemForm')">确定</Button>
                <Button type="primary" class='ivu-btn-cancel' @click="itemModel=false,briefItem={}">取消</Button>
                <!--<Button v-if="mode === 'view'" class='ivu-btn-save' @click="dialogShow=false">关闭</Button>-->
            </div>
        </Modal>

        <Modal :transfer=false v-model="model4" :width=900>
            <Tabs>
                <TabPane label="历史记录">
                    <Table ref='table1' border :columns="columns2" no-data-text="没有查询到相关数据！" style="margin-top: 0"
                           :loading="loading2"
                           :data="history" width="100%" :height="450" highlight-row stripe size="small"></Table>
                </TabPane>
                <TabPane label="流程图">
                    <div style="height: 450px; overflow-y: auto; overflow-x: auto">
                        <img :src="imgUrl">
                    </div>
                </TabPane>
            </Tabs>
            <div slot="footer">
                <Button @click="model4=false" class="ivu-btn-save">关闭</Button>
            </div>
        </Modal>

        <div v-show="downloading"
             style="position:absolute;top:0;left:0;width:100%;height:100%;z-index:99999;background-color:#000000;opacity:0.5;">
            <svg-bar style="position:absolute;top:50%;left:50%;margin-left:-100px;margin-top:-100px"
                     :options="options" :value="batchProcess"></svg-bar>
        </div>
    </Layout>
</template>

<script>
    import {Api} from '../../../../api/index.js'
    import {sessionStorage} from '../../../../common/cacheUtils.js';
    import {formatDate} from "@/tools";
    import pageCommonFunction from '@/components/pageCommonFunction.js'
    import svgBar from 'svg-progress-bar'
    export default {
        components: {svgBar},
        name: "briefingList",
        data() {
            return {
                ...this.createCommonDataField(),
                buttonLoading: false,
                loading: false,
                loading2: false,
                daysWork: false,

                columns2: [
                    {type: 'index', title: '序号', width: 80, align: 'center',},
                    {width: 180, title: '审批时间', key: 'endTime', align: 'center',},
                    {width: 185, title: '节点名称', key: 'name', align: 'center',},
                    {width: 120, title: '审批人', key: 'userName', align: 'center'},
                    {width: 100, title: '审批意见', key: 'route', align: 'center'},
                    {width: 200, title: '备注', key: 'opinions', align: 'center'},
                ],
                tableHeight: 10,
                sexList: [
                    {value: '0', text: '男'},
                    {value: '1', text: '女'}
                ],

                ruleCustom: {
                    daysWork: [{required: true, message: ' ', trigger: 'change', type: 'number'}],
                    loseMoney: [{
                        required: true, trigger: 'change', message: '请填写0-9数字包括小数',
                        validator: (rule, value, callback) => {
                            if (!(/^(([^0][0-9]+|0)\.([0-9]{1,8})$)|^(([^0][0-9]+|0)$)|^(([1-9]+)\.([0-9]{1,8})$)|^(([1-9]+)$)/.test(value))) {
                                callback(' ');
                            } else {
                                callback()
                            }
                        },
                    }],
                    groupPersionId: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.groupPersionId == null || this.dataToView.groupPersionId == '' || this.dataToView.groupPersionId == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    chargeId: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.chargeId == null || this.dataToView.chargeId == '' || this.dataToView.chargeId == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    secondaryGroupPersionId: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.secondaryGroupPersionId == null || this.dataToView.secondaryGroupPersionId == '' || this.dataToView.secondaryGroupPersionId == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    accAnalyze: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.accAnalyze == null || this.dataToView.accAnalyze == '' || this.dataToView.accAnalyze == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    accDesc: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.accDesc == null || this.dataToView.accDesc == '' || this.dataToView.accDesc == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    briefIdFiles: [{
                        validator: (rule, value, callback) => {
                            if (this.dataToView.briefIdFiles.length < 1) {
                                callback('附件必须上传')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    sartDate: [{message: '  ', required: true, trigger: 'change', type: 'date'}],
                    accTypeId: [{message: '  ', required: true, trigger: 'change'}],
                    // membershipId: [{message: '  ', required: true, trigger: 'change'}],
                    // injuryLevelId: [{message: '  ', required: true, trigger: 'change'}],
                    phone: [{
                        validator: (rule, value, callback) => {
                            if (!(/^1[3456789]\d{9}$/.test(value))) {
                                callback(' ');
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],

                },
                columns: [
                    {type:'expand', width:30,
                        fixed: 'left',
                        _disableExpand:true,
                        render:(h,params)=>{
                            return h('Table',{
                                props: {
                                    columns: [
                                        {title: '伤亡人员姓名', align: 'center', key: 'victim', minWidth: 100,},
                                        {title: '性别', align: 'center', key: 'gender', minWidth: 80, render: (h, params) => {
                                                return h('span', params.row.gender == '0' ? '男' : '女')}},
                                        {title: '年龄', align: 'center', key: 'age', minWidth: 80,},
                                        {title: '工种或岗位', align: 'center', key: 'position', minWidth: 120,},
                                        {title: '伤害部位', align: 'center', key: 'injured', minWidth: 120,},
                                        {title: '就业类型', align: 'center', key: 'membershipName', minWidth: 120,},
                                        {title: '伤害程度', align: 'center', key: 'injuryLevelName', minWidth: 120,},
                                        {title: '歇工天数', align: 'center', key: 'daysWork', minWidth: 100,},
                                        {title: '直接经济损失(万元)', align: 'center', key: 'loseMoney', minWidth: 130,},
                                    ],//表头
                                    data: params.row.briefItems,//内部表格展示的数据
                                },
                            })//我这里使用的是表格，大家也可以根据自己的实际情况更换别的组件
                        }
                    },
                    {title: "序号", key: 'index', width: 65, align: "center", fixed: 'left', render: this.indexColumnsRenderSum},
                    {
                        title: '状态', align: 'center', key: 'status', width: 90,name:'1',
                        render: (h, params) => {
                            if (params.row.briefId==='-1') return h('span','')
                            let color = 'green';
                            if (params.row.procinstState == undefined || params.row.procinstState == null || params.row.procinstState == 2) {
                                color = 'red';
                            }
                            if (params.row.procinstState == 1) {
                                color = 'blue';
                            }
                            return h('div', [h('span', {style: {color: color}},
                                params.row.procinstState == 1 ? '审批中' : params.row.procinstState == 2 ? '被退回' : params.row.procinstState == 3 ? '审批通过' : '未上报' || '--')]);
                        }
                    },
                    // {title: '上报状态', align: 'center', key: 'reportState', minWidth: 120,},
                    {
                        title: '上报状态', align: 'center', key: 'reportState', minWidth: 100,name:'1',
                        render: (h, params) => {return h('span', {style: {color: params.row.reportState && params.row.reportState.indexOf('迟报')>-1 ? 'red' : ''}}, params.row.reportState)}
                    },
                    {title: '工伤上报情况', align: 'center', key: 'injuryDesc', minWidth: 140,},
                    // {title: '伤亡人员姓名', align: 'center', key: 'victim', minWidth: 120,},
                    {title: '事故名称', align: 'center', key: 'sartName', minWidth: 140,},
                    {title: '上报单位', align: 'center', key: 'orgName', minWidth: 200, tooltip: true},
                    {title: '伤害程度描述', align: 'center', key: 'injuryLevelDesc', minWidth: 180,tooltip:true},
                    {title: '歇工天数', align: 'center', key: 'daysWork', minWidth: 100,},
                    {title: '直接经济损失(万元)', align: 'center', key: 'loseMoney', minWidth: 150,},
                    // {title: '工种或岗位', align: 'center', key: 'position', minWidth: 150,},
                    {title: '事故时间', sortable: "custom", align: 'center', key: 'sartDate', minWidth: 100, render: this.renderCellDate},
                    {title: '上报时间', sortable: "custom", align: 'center', key: 'reportDate', minWidth: 100, render: this.renderCellDate},
                    {title: '事故类别', align: 'center', key: 'accTypeName', minWidth: 120,},
                    // {title: '就业类型', align: 'center', key: 'membershipName', minWidth: 150,},
                    {title: '二级集团', align: 'center', key: 'twoLevelOrgName', minWidth: 180,},
                    {title: '操作', key: 'action', fixed: 'right', width: 280, align: 'center',name:'1',
                        render: (h, params) => {
                            if (params.row.briefId==='-1') return h('div','')
							let isBelongOrg = this.Common.belongOrgId.includes(this.currentUser.companyId) || this.Common.jinyuOrgId==this.currentUser.companyId
                            return h('div', [
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                    },
                                    on: {
                                        click: () => {
                                            this.viewData(params);
                                        }
                                    }
                                }, '详情'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: isBelongOrg?'':(params.row.procinstState == "1" || params.row.procinstState == "2" || params.row.procinstState == "3") ? '#d0d0d0' : params.row.createUserId == this.currentUser.userId || this.Common.userIdList.includes(this.currentUser.userId) || this.currentUser.userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined || this.currentUser.userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined ? '' : '#d0d0d0',
                                        pointerEvents: isBelongOrg?'':(params.row.procinstState == "1" || params.row.procinstState == "2" || params.row.procinstState == "3") ? 'none' : params.row.createUserId == this.currentUser.userId || this.Common.userIdList.includes(this.currentUser.userId) || this.currentUser.userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined || this.currentUser.userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined ? '' : 'none'
                                    },
                                    on: {
                                        click: () => {
											this.isBelongOrg = isBelongOrg && (params.row.procinstState == "1" || params.row.procinstState == "2" || params.row.procinstState == "3")
                                            this.editData(params);
                                        }
                                    }
                                }, '修改'), h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.procinstState == "1" || params.row.procinstState == "2" || params.row.procinstState == "3" ? '#d0d0d0' : params.row.createUserId == this.currentUser.userId || this.Common.userIdList.includes(this.currentUser.userId) ? '' : '#d0d0d0',
                                        pointerEvents: params.row.procinstState == "1" || params.row.procinstState == "2" || params.row.procinstState == "3" ? 'none' : params.row.createUserId == this.currentUser.userId || this.Common.userIdList.includes(this.currentUser.userId) ? '' : 'none'
                                    },
                                    on: {
                                        click: () => {
                                            this.$Modal.confirm({
                                                title: '提示',
                                                content: '<p>是否要提交？</p>',
                                                onOk: () => {
                                                    this.reportInfo(params.row);
                                                },
                                                onCancel: () => {
                                                }
                                            });


                                        }
                                    }
                                }, '上报'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'error',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.procinstState == "1" || params.row.procinstState == "2" || params.row.procinstState == "3" ? '#d0d0d0' : params.row.createUserId == this.currentUser.userId || this.Common.userIdList.includes(this.currentUser.userId) || this.currentUser.userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined || this.currentUser.userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined ? 'red' : '#d0d0d0',
                                        pointerEvents: params.row.procinstState == "1" || params.row.procinstState == "2" || params.row.procinstState == "3" ? 'none' : params.row.createUserId == this.currentUser.userId || this.Common.userIdList.includes(this.currentUser.userId) || this.currentUser.userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined || this.currentUser.userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined? '' : 'none'
                                    },
                                    on: {
                                        click: () => {
                                            this.deleteData(params);
                                        }
                                    }
                                }, '删除'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('a', {
                                    props: {
                                        type: 'primary',
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.procinstId == null ? '#d0d0d0' : '',
                                        pointerEvents: params.row.procinstId == null ? 'none' : ''
                                    },
                                    on: {
                                        click: () => {
                                            this.imgUrl = Api.getFlowImg + '/' + params.row.procinstId
                                            this.showHistory(params.row);
                                        }
                                    }
                                }, '审批记录')
                            ]);
                        }
                    },
                    {title: '操作', key: 'action', fixed: 'right', width: 100, align: 'center',name:'0',
                        render: (h, params) => { return h('div', [
                            h('A', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    fontSize: '14px',
                                },
                                on: {
                                    click: () => {
                                        this.viewData(params);
                                    }
                                }
                            }, '详情'),
                        ]);
                        }

                    }
                ],

                groupPersionList: [],
                secondaryGroupPersionList: [],
                chargeList: [],
                history: [],
                twoOrgList: [],
                imgUrl:'',
                model4: false,


                exportUrl: Api.briefingDownload,
                queryUrl: Api.briefing + '/list',
                deleteUrl: Api.briefing + '/',
                updateUrl: Api.briefing,
                saveUrl: Api.briefing,

                dictMap: {},
                briefItem: {},
                itemModel: false,
                itemAdd: false,
                columnsItem: [
                    {title: '序号', width: 70, align: 'center', render: this.indexColumnsRender},
                    {title: '伤亡人员姓名', align: 'center', key: 'victim', minWidth: 100,},
                    {
                        title: '性别', align: 'center', key: 'gender', minWidth: 80, render: (h, params) => {
                            return h('span', params.row.gender == '0' ? '男' : '女')
                        }
                    },
                    {title: '年龄', align: 'center', key: 'age', minWidth: 80,},
                    {title: '工种或岗位', align: 'center', key: 'position', minWidth: 120,},
                    {title: '伤害部位', align: 'center', key: 'injured', minWidth: 120,},
                    {title: '就业类型', align: 'center', key: 'membershipName', minWidth: 120,},
                    {title: '伤害程度', align: 'center', key: 'injuryLevelName', minWidth: 120,},
                    {title: '歇工天数', align: 'center', key: 'daysWork', minWidth: 100,},
                    {title: '直接经济损失(万元)', align: 'center', key: 'loseMoney', minWidth: 120,},
                    {
                        title: '操作',
                        key: 'action',
                        fixed: 'right',
                        width: 110,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {fontSize: '13px',},
                                    on: {
                                        click: () => {
                                            this.briefItem = {...params.row}
                                            this.itemModel = true
                                            this.itemAdd = false
                                        }
                                    }
                                }, '修改'),
                                h('Divider', {props: {type: 'vertical'}}, ''),
                                h('A', {
                                    props: {type: 'primary', size: 'small'},
                                    style: {
										fontSize: '13px', 
										color: this.isBelongOrg?'#d0d0d0':'red',
										pointerEvents: this.isBelongOrg?'none':''
									},
                                    on: {
                                        click: () => {
                                            this.$Modal.confirm({
                                                title: '提示',
                                                content: '<p>是否要删除？</p>',
                                                onOk: () => {
                                                    this.dataToView.briefItems.splice(params.index, 1)
                                                    this.dataToView.loseMoney = 0
                                                    this.dataToView.daysWork = 0
                                                    this.dataToView.injuryLevelId = ''
                                                    let victim = []
                                                    this.dataToView.briefItems.forEach(m => {
                                                        this.dataToView.loseMoney += m.loseMoney
                                                        if (m.injuryLevelId !== '1000001019000000003') {
                                                            this.dataToView.daysWork += m.daysWork
                                                        }
                                                        victim.push(m.victim)
                                                        if (m.injuryLevelId > this.dataToView.injuryLevelId) {
                                                            this.dataToView.injuryLevelId = m.injuryLevelId
                                                        }
                                                    })
                                                    this.dataToView.victim = victim.join(',')
                                                    this.itemModel = false
                                                }
                                            })
                                        }
                                    }
                                }, '删除'),
                            ])
                        }
                    }
                ],
                itemRuleCustom: {
                    victim: [{required: true, message: '请填写伤亡人员姓名', trigger: 'change'}],
                    gender: [{required: true, message: '请选择性别', trigger: 'change'}],
                    age: [{required: true, message: '请填写年龄', trigger: 'change',pattern: /^[0-9]*$/,}],
                    position: [{required: true, message: '请填写工种或岗位', trigger: 'change'}],
                    injured: [{required: true, message: '请填写伤害部位', trigger: 'change'}],
                    membershipId: [{required: true, message: '请选择就业类型', trigger: 'change'}],
                    injuryLevelId: [{required: true, message: '请选择伤害程度', trigger: 'change'}],
                    // daysWork: [{required: true, message: '请填写歇工天数', trigger: 'change', type: 'number'}],
                    daysWork:[{
                        validator: (rule, value, callback) => {
                            let _this = this
                            if (value === null || value === '' || value === undefined) {
                                callback(' ')
                            } else {
                                if (_this.briefItem.membershipId !== 'MEM-000001000000004') {
                                    if (_this.briefItem.injuryLevelId === '1000001019000000002'&&_this.briefItem.daysWork<105) {
                                        callback(' ')
                                    }if (_this.briefItem.injuryLevelId === '1000001019000000001'&&_this.briefItem.daysWork>=105) {
                                        callback(' ')
                                    } else {
                                        callback()
                                    }
                                } else {
                                    callback()
                                }
                            }
                        },
                        required: true,
                        trigger: 'change'
                    }],
                    loseMoney: [{required: true, message: '请填写直接经济损失', trigger: 'change', type: 'number'}],
                },
                currentUser: JSON.parse(sessionStorage('userId').get('userId')),
				isBelongOrg: false,
                batchProcess:0,
                downloading:false,
                titCount:"",
				modaleShow: 1,
            }
        },
        computed: {
            isResult() {
                return this.$route.name === 'briefingList'//true事故简报  false事故事件月报
            },
            columns1() {
                const columns = [...this.columns];
                const columns1 = []
                columns.forEach(item => {
                    if (this.isResult) {
                        if (item.name !== '0') {
                            columns1.push(item)
                        }
                    } else {
                        if (item.name !== '1') {
                            columns1.push(item)
                        }
                    }
                })
                return columns1
            },
            itemColumn() {
                const columns = [...this.columnsItem];
                const columns1 = []
                columns.forEach(item => {
                    if (this.mode !== 'view') {
                        columns1.push(item)
                    } else {
                        if (item.key !== 'action') {
                            columns1.push(item)
                        }
                    }
                })
                return columns1
            },
            options: function() {
                return {
                    radius: 50,//大小
                    duration: 2,//变化时间长度
                    circleWidth: 5,//圆环宽度
                    pathColors: ['#A2A2A2', '#FA5657'], //圆环 底色和 上面的颜色
                    circleLineCap: 'round',//进度条 形状  圆环 或者矩形
                    text: function (value) {
                        return this.htmlifyNumber(value) + '<span style="font-size: 0.4em;">%</span>';
                    },
                    textColor: 'rgb(33, 150, 243)'
                }
            }
        },
        async mounted() {
            this.dataToQuery.year1 = new Date()
            this.dataToQuery.year = new Date().getFullYear().toString()
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 193;
            //企业负责人
            this.$http.get(Api.queryRoleUser + "/" + "cfb951f2448f44a6ba805e1d5313fa75", {params: {orgId: this.currentUser.companyId}}).then((res) => {
                this.chargeList = res.data.data;
            }).catch(e => {
                this.$Message.error("数据获取失败")
            });
            this.$http.get(Api.getTwoOrgInfo).then((res) => {
                this.twoOrgList = res.data.data;
            }).catch(e => {
                this.$Message.error("数据获取失败")
            });
            //二级集团
            this.$http.get(Api.queryRoleUser + "/" + "843197356dd443d099542d7ebe22b2be", {
                params: {
                    orgId: this.currentUser.twoLevelOrgId,
                    two: true
                }
            }).then((res) => {
                this.secondaryGroupPersionList = res.data.data;
            }).catch(e => {
                this.$Message.error("数据获取失败")
            });
            //集团
            this.$http.get(Api.queryRoleUser + "/" + "17744170d3c24383bd283fbe72f3d664").then((res) => {
                this.groupPersionList = res.data.data;
            }).catch(e => {
                this.$Message.error("数据获取失败")
            });
            // this.query()

            await this.$http.get(Api.queryDictBycode + "MEM-000001,ACC-000001,1000001019", {}).then((res) => {
				let membershipList = []
				res.data.data['MEM-000001'].forEach(m=>{
					m.disabledType = m.codingCodeId == 'MEM-000001000000004'
					membershipList.push(m)
				})
                this.dictMap = {
                    'membershipList': membershipList,
                    'typeList': res.data.data['ACC-000001'],
                    'injuryLeveList': res.data.data['1000001019']
                }
            }).catch(e => {
                this.$Message.error("数据字典获取失败")
            });
			
			// this.tableHeight = window.innerHeight - 325
			this.lowerStep(this.modaleShow)
            this.$Loading.config({
                color: '#5cb85c',
                failedColor: 'red',
                height: 5
            });
        },
        methods: {
            ...pageCommonFunction,
            // 展开原生事件  点击左侧展收起
            batchDownload(){
                var _this = this;
                _this.downloading = true
                var url = Api.mongoBatchDownload;
                var ids = [];
                var fileNames = [];
                _this.dataTable.forEach(item=>{
                    if (item.briefId != -1) {
                        ids.push(item.briefId)
                        fileNames.push(item.reportOrgName+'-'+_this.renderViewDate(item.sartDate)+'-'+item.accTypeName)
                    }
                })
                let formData = new FormData();
                formData.append("ids", ids); // 文件对象
                formData.append("fileNames", fileNames); // 文件对象
                _this.$http.post(url, formData, {
                    responseType: 'blob',      //告诉服务器我们需要的响应格式
                    progress:function(e){
                        _this.batchProcess = 100 * (e.loaded / e.total);
                        if(_this.batchProcess == 100){
                            _this.downloading = false;
                        }
                    }
                }).then((res) => {
                    const aLink = document.createElement("a");
                    let blob = new Blob([res.data], {
                        type: 'application/zip'     //将会被放入到blob中的数组内容的MIME类型
                    });
                    aLink.href = URL.createObjectURL(blob)
                    aLink.download = _this.formatDate(new Date(), 'yyyyMMddhhmmss') + ".zip";
                    aLink.click()
                    document.body.appendChild(aLink)
                }, function(res){
                    _this.$Loading.error();
                })
            },
            onExpand(row, status){
                if(status){
                    this.dataTable.splice()
                    this.dataTable.filter((item, index)=>{
                        if(item.briefId == row.briefId){
                            item._expanded = true;   //展开选中的行
                        }else{
                            item._expanded = false;   //其他行关闭
                        }
                        return item;
                    });
                }else{
                    this.dataTable.splice()
                    this.dataTable.map((item, index)=>{
                        if(item.briefId == row.briefId){
                            item._expanded = false;   //展开选中的行
                        }else{
                            item._expanded = false;   //其他行关闭
                        }
                        return item;
                    });
                }
            },

            selectInJuryLevelId(value) {
                this.briefItem.injuryLevelId = value.value;
                this.briefItem.injuryLevelName = value.label;
                if (this.briefItem.membershipId === 'MEM-000001000000004' && value.value === '1000001019000000003') {
                    this.briefItem.daysWork = 0;
                } else {
                    if (value.value === '1000001019000000003') {
                        this.briefItem.daysWork = 6000;
                    }
                }
            },
            selectMembership(value) {
                this.briefItem.membershipId = value.value;
                this.briefItem.membershipName = value.label;
                if (value.value === 'MEM-000001000000004') {
                    this.daysWork = true;
                    this.briefItem.daysWork = 0;
                } else {
                    this.daysWork = false;
                    if (this.briefItem.injuryLevelId === '1000001019000000003') {
                        this.briefItem.daysWork = 6000;
                    }
                }
            },


            showHistory(row) {
                this.model4 = true;
                this.loading2 = true;
                this.$http.get(Api.getHistory + '/' + row.procinstId, {params: {}}).then((res) => {
                    this.history = res.data;
                    this.loading2 = false;
                }).catch(e => {
                    this.$Message.error("数据获取失败")
                })
            },
            reportInfo(row) {
                this.loading = true;
                let data = {
                    key: "briefingList",
                    createUserId: this.currentUser.userId,
                    userName: this.currentUser.userName,
                    workId: row.briefId,
                    type: "sgjb",
                    formKey: "briefingListForApproval",
                    user1: row.chargeId,
                    user2: row.secondaryGroupPersionId,
                    user3: row.groupPersionId,
                };
                this.$http.post(Api.submit, data).then(function (res) {
                    this.loading = false;
                    this.$Message.success({
                        content: '上报成功',
                        duration: 4
                    });
                    this.query();
                }, function (err) {
                    this.loading = false;
                    this.$Message.error({
                        content: '上报失败',
                        duration: 4
                    });
                });


            },

            // charge(value) {
            //     this.dataToView.chargeId = value.value;
            //     this.dataToView.charge = value.label;
            // },
            // secondaryGroupPersion(value) {
            //     this.dataToView.secondaryGroupPersionId = value.value;
            //     this.dataToView.secondaryGroupPersion = value.label;
            // },
            // groupPersion(value) {
            //     this.dataToView.groupPersionId = value.value;
            //     this.dataToView.groupPersion = value.label;
            // },

            addItem() {
                this.itemModel = true
                this.itemAdd = true;
                this.briefItem = {loseMoney: 0, daysWork: 0, age: 1}
            },
            itemSubmit(name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.$Modal.confirm({
                            title: '提示',
                            content: '<p>是否要提交？</p>',
                            onOk: () => {
                                let _this = this
                                _this.dataToView.briefItems.splice()
                                if (_this.itemAdd) {
                                    _this.dataToView.briefItems.push(_this.briefItem)
                                } else {
                                    _this.dataToView.briefItems[_this.briefItem._index] = _this.briefItem
                                }
                                _this.dataToView.loseMoney = 0
                                _this.dataToView.daysWork = 0
                                let victim = []
                                _this.dataToView.injuryLevelId = ''
                                _this.dataToView.briefItems.forEach(m => {
                                    _this.dataToView.loseMoney += m.loseMoney
                                    if (m.injuryLevelId !== '1000001019000000003') {
                                        _this.dataToView.daysWork += m.daysWork
                                    }
                                    victim.push(m.victim)
                                    if (m.injuryLevelId > _this.dataToView.injuryLevelId) {
                                        _this.dataToView.injuryLevelId = m.injuryLevelId
                                    }
                                })
                                _this.dataToView.victim = victim.join(',')
                                _this.itemModel = false
                            },
                            onCancel: () => {
                            }
                        })
                    } else {
                        this.$Message.error('请填报完整!');
                    }
                })
            },

            submit(name) {
                if (this.dataToView.briefItems.length < 1) {
                    this.$Message.warning('伤亡人员至少填报一条');
                } else {
                    if (this.mode === 'add') {
                        this.dataToView.createOrgId = this.currentUser.orgInfo.orgId
                        this.dataToView.createUserId = this.currentUser.userId
                        this.dataToView.reportOrgId = this.currentUser.companyId
                        this.dataToView.reportOrgName = this.currentUser.companyName
                    }
                    let sartDate = this.renderViewDate(this.dataToView.sartDate)
                    this.dataToView.sartName = sartDate + '伤亡事故(' + this.dataToView.victim + ')'
                    this.submitAjax(name);
                }
            },
            deleteData(params) {
                params.row.id = params.row.briefId
                this.deleteDateAjax(params);
            },

            createEmptyDataToAdd() {
				this.isBelongOrg = false
                return {
                    briefId: this.get_uuid(),
                    briefIdFiles: [],
                    briefItems: [],
                    phone: this.currentUser.mobileNumber,
                    userName: this.currentUser.userName,
                    age: 0,
                    // injuryLevelId:'1000001019000000001',//
                    daysWork: 0,
                    loseMoney: 0,
                }
            },
            reset1(){
                this.dataToQuery = {};
                this.pagedata.currentPage=1
                this.lowerStep(this.modaleShow)
            },
            lowerStep(name) {
                this.modaleShow = name
				this.dataToQuery.memberships = name==1?['MEM-000001000000001','MEM-000001000000002','MEM-000001000000003']:['MEM-000001000000004']
                this.setTableHeight(193)
                this.query();
            
            },
			query() {
                this.dataToQuery.type = '1';
                if (this.dataToQuery.injuryLevels != null && this.dataToQuery.injuryLevels != undefined && this.dataToQuery.injuryLevels.length < 1) {
                    delete this.dataToQuery.injuryLevels;
                }
                if (this.dataToQuery.memberships != null && this.dataToQuery.memberships != undefined && this.dataToQuery.memberships.length < 1) {
					this.dataToQuery.memberships = this.modaleShow==1?['MEM-000001000000001','MEM-000001000000002','MEM-000001000000003']:['MEM-000001000000004']
                    // delete this.dataToQuery.memberships;
                }
                if (this.dataToQuery.accTypeIds != null && this.dataToQuery.accTypeIds != undefined && this.dataToQuery.accTypeIds.length < 1) {
                    delete this.dataToQuery.accTypeIds;
                }
                if (this.dataToQuery.twoLevelOrgIds != null && this.dataToQuery.twoLevelOrgIds != undefined && this.dataToQuery.twoLevelOrgIds.length < 1) {
                    delete this.dataToQuery.twoLevelOrgIds;
                }
                if (!this.isResult) {
                    this.dataToQuery.procinstState = '3';
                    // delete this.dataToQuery['type']
                }
                this.queryAjax();
            },
            queryAjax() {
                this.pageStatus.loading = true
                let data = {
                    startPage: this.pagedata.currentPage,
                    size: this.pagedata.pageSize,
                    conditions: this.dataToQuery
                };

                this.$http.post(this.queryUrl, data).then((res) => {
                    if (res.data.status === 201) {
                        this.$Message.error(res.data.msg);
                    }
                    this.dataTable = res.data.data.data;
                    this.titCount = res.data.data.titCount;
                    this.pagedata.total = res.data.data.totalSize;
                    this.pageStatus.loading = false
                }).catch(e => {
                    this.$Message.error("数据获取失败")
                    this.pageStatus.loading = false
                })
            },
            exportSubmit(){
                if (this.dataToQuery.injuryLevels != null && this.dataToQuery.injuryLevels != undefined && this.dataToQuery.injuryLevels.length < 1) {
                    delete this.dataToQuery.injuryLevels;
                }
                if (this.dataToQuery.memberships != null && this.dataToQuery.memberships != undefined && this.dataToQuery.memberships.length < 1) {
                    this.dataToQuery.memberships = this.modaleShow==1?['MEM-000001000000001','MEM-000001000000002','MEM-000001000000003']:['MEM-000001000000004']
                    // delete this.dataToQuery.memberships;
                }
                if (this.dataToQuery.accTypeIds != null && this.dataToQuery.accTypeIds != undefined && this.dataToQuery.accTypeIds.length < 1) {
                    delete this.dataToQuery.accTypeIds;
                }
                if (this.dataToQuery.twoLevelOrgIds != null && this.dataToQuery.twoLevelOrgIds != undefined && this.dataToQuery.twoLevelOrgIds.length < 1) {
                    delete this.dataToQuery.twoLevelOrgIds;
                }
                this.exportFormSubmit()
            },
            // beforeEditDialogOpen(data) {
            //     if (data.row.membershipId === 'MEM-000001000000004') {
            //         this.daysWork = true;
            //     } else {
            //         this.daysWork = false;
            //     }
            // },
            async afterDataToViewInit() {
                await this.getFiles('briefId');
            },

            formatDate(date, fmt) {
                if (typeof date == 'string') {
                    return date;
                }
                if (!fmt) fmt = "yyyy-MM-dd hh:mm:ss";
                if (!date || date == null) return null;
                let o = {
                    'M+': date.getMonth() + 1, // 月份
                    'd+': date.getDate(), // 日
                    'h+': date.getHours(), // 小时
                    'm+': date.getMinutes(), // 分
                    's+': date.getSeconds(), // 秒
                    'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
                    'S': date.getMilliseconds() // 毫秒
                }
                if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
                for (let k in o) {
                    if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
                }
                return fmt
            },
        },
        watch: {
            '$route.name': function () {
                this.reset()
            },
            'dataTable': function () {
                this.dataTable.forEach(m=>{
                    if (m.briefId === '-1') {
                        m['_disableExpand'] = true
                    }
                })
            },
			'modaleShow':function (name) {
			    let membershipList = []
			    if (name == 1) {
					this.dictMap.membershipList.forEach(m=>{
						m.disabledType = m.codingCodeId == 'MEM-000001000000004'
						membershipList.push(m)
					})
				} else {
					this.dictMap.membershipList.forEach(m=>{
						m.disabledType = m.codingCodeId !== 'MEM-000001000000004'
						membershipList.push(m)
					})
				}
				this.dictMap.membershipList = membershipList
			}
        }
    }
</script>

<style scoped>
    @import '../../../../index.css';

</style>
